<!doctype html>
<html  class="x-admin-sm">
<head>
	<meta charset="UTF-8">
	<title>后台登录</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="__ADMIN__/css/login.css">
    {include file="public/style"}
    {include file="public/script"}
</head>
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">后台管理</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <i></i>
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input">
            <i></i>
            <hr class="hr15">
            <input name="code" id="code" lay-verify="required" placeholder="验证码"  type="text" class="layui-input" style="width:180px;display: inline;" />
            <img id="imgVcode" src="{:url('login/verify')}" alt="验证码" style="width:150px;height: 50px;display: inline;cursor: pointer;" />
            <i></i>
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="*" style="width:100%;" type="submit">
            <hr class="hr20" >
        </form>
    </div>

    <script>
        //点击图片更换验证码    拼接时间戳
        $("#imgVcode").click(function() {
            $(this).attr('src', "{:url('login/verify')}?d="+Math.random());
        });

        $("input").focus(function(){
            $(this).css("color","#008DE8");
        })

        $("input").blur(function(){
            $(this).css("color","#555555");

        })
        $("input").bind('input propertychange',function(){
            var u = $("#username").val();
            var p = $("#password").val();
            var c = $("#code").val();
            if(u && p && c){
                $("#login").css("background","#189F92");
                $("#login").removeAttr("disabled");
            }
            if(u == "" || p == "" || c == ""){
                $("#login").css("background","grey");
                $("#login").attr("disabled","disabled");
            }
        });

        $("#code").blur(function(){
            var v = $(this).val();
            if(v == ""){
                $(this).next().next().text("*验证码码不能为空").css("color","#ff0000");
            }else{
                $(this).next().next().remove();
            }
        })

        layui.use(['form', 'layedit', 'laydate'], function(){
            var $ = layui.$;
            var form = layui.form
                ,layer = layui.layer
                ,layedit = layui.layedit
                ,laydate = layui.laydate;


            //监听提交
            var url = 'login/verifyLogin';
            form.on('submit(*)', function(data){
                $.ajax({
                    url: url,
                    type:"POST",
                    dataType:"json",
                    data:data.field,
                    success:function(data){
                        if(data.code == 1){
                            layer.msg(data.msg, {icon: 1, time: 400}, function (data) {
                                // 可以对当前口进行刷新
                                location.href = 'index/index'
                            });
                        }else{
                            layer.msg(data.msg, {icon: 5, time: 1000}, function (data) {
                                // 可以对当前口进行刷新
                                location.reload();
                            });
                        }
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>